<?php
class CustomerOrderEntityBase extends EntityBase
{
	public $id;
	public $customers_id;
	public $customers_name;
	public $customers_company;
	public $customers_street;
	public $customers_suburb;
	public $customers_city;
	public $customers_postcode;
	public $customers_state;
	public $customers_country;
	public $customers_telephone;
	public $customers_email;
		
	public $delivery_name;
	public $delivery_company;
	public $delivery_street;
	public $delivery_suburb;
	public $delivery_city;
	public $delivery_postcode;
	public $delivery_state;
	public $delivery_country;
	
	public $billing_name;
	public $billing_company;
	public $billing_street;
	public $billing_suburb;
	public $billing_city;
	public $billing_postcode;
	public $billing_state;
	public $billing_country;
	
	public $payment_method;
	public $last_modified;
	public $date_purchased;
	public $orders_status;
	public $orders_date_finished;
	public $currency;
	public $currency_value;
	public $paygate_order_id;
	public $shipping_method;
	
	const INACTIVE = 0;
	const ACTIVE = 1;
	public function __construct($arrValue = null, $prefix = '')
	{
		if(!is_null($arrValue) && is_array($arrValue))
		{
			$this->id = (int) ($arrValue[$prefix . 'id']);			
			$this->customers_city = strval ($arrValue[$prefix . 'customers_city']);
			$this->customers_company = strval ($arrValue[$prefix . 'customers_company']);
			$this->customers_country = strval ($arrValue[$prefix . 'customers_country']);
			$this->customers_email = strval ($arrValue[$prefix . 'customers_email']);
			$this->customers_id = strval ($arrValue[$prefix . 'customers_id']);
			$this->customers_name = strval ($arrValue[$prefix . 'customers_name']);
			$this->customers_postcode = strval ($arrValue[$prefix . 'customers_postcode']);
			$this->customers_state = strval ($arrValue[$prefix . 'customers_state']);
			$this->customers_street = strval ($arrValue[$prefix . 'customers_street']);
			$this->customers_suburb = strval ($arrValue[$prefix . 'customers_suburb']);
			$this->customers_telephone = strval ($arrValue[$prefix . 'customers_telephone']);

			$this->billing_city = strval ($arrValue[$prefix . 'billing_city']);
			$this->billing_company = strval ($arrValue[$prefix . 'billing_company']);
			$this->billing_country = strval ($arrValue[$prefix . 'billing_country']);
			$this->billing_name = strval ($arrValue[$prefix . 'billing_name']);
			$this->billing_postcode = strval ($arrValue[$prefix . 'billing_postcode']);
			$this->billing_state = strval ($arrValue[$prefix . 'billing_state']);
			$this->billing_street = strval ($arrValue[$prefix . 'billing_street']);
			$this->billing_suburb = strval ($arrValue[$prefix . 'billing_suburb']);
			
			$this->delivery_city = strval ($arrValue[$prefix . 'delivery_city']);
			$this->delivery_company = strval ($arrValue[$prefix . 'delivery_company']);
			$this->delivery_country = strval ($arrValue[$prefix . 'delivery_country']);
			$this->delivery_name = strval ($arrValue[$prefix . 'delivery_name']);
			$this->delivery_postcode = strval ($arrValue[$prefix . 'delivery_postcode']);
			$this->delivery_state = strval ($arrValue[$prefix . 'delivery_state']);
			$this->delivery_street = strval ($arrValue[$prefix . 'delivery_street']);
			$this->delivery_suburb = strval ($arrValue[$prefix . 'delivery_suburb']);
			
			$this->payment_method = strval ($arrValue[$prefix . 'payment_method']);
			$this->last_modified = strval ($arrValue[$prefix . 'last_modified']);
			$this->date_purchased = strval ($arrValue[$prefix . 'date_purchased']);
			$this->orders_date_finished = strval ($arrValue[$prefix . 'orders_date_finished']);
			$this->orders_status = strval ($arrValue[$prefix . 'orders_status']);
			$this->currency = strval ($arrValue[$prefix . 'currency']);
			$this->currency_value = strval ($arrValue[$prefix . 'currency_value']);
			$this->paygate_order_id = strval($arrValue[$prefix . 'paygate_order_id']);
			$this->shipping_method = strval($arrValue[$prefix . 'shipping_method']);
		}
	}

	/**
	 * Get status name of users
	 *
	 * @access public
	 *
	 * @return string name of status
	 *
	 */
	public function getStatusName()
	{
		$arrStatusList = self::getStatusList();
		return isset($arrStatusList["{$this->status}"]) ? $arrStatusList["{$this->status}"] : '';
	}

	/**
	 * Get list of users status
	 *
	 * @access public
	 *
	 * @return array of users status
	 *
	 */
	public static function getStatusList()
	{
		return array(self::INACTIVE	=> 'INACTIVE',
		self::ACTIVE 	=>'ACTIVE'		
		);
	}

	/**
	 * Get all fields for selecting columns
	 *
	 * @param string $alias: alias of table
	 * @param string $prefix
	 * @return string
	 */
	public static function getSelectColumns($alias, $prefix = '')
	{
		$arrValue = array(
						"{$alias}.id AS `{$prefix}id`",
						"{$alias}.customers_city AS `{$prefix}customers_city`",
						"{$alias}.customers_company AS `{$prefix}customers_company`",
						"{$alias}.customers_country AS `{$prefix}customers_country`",
						"{$alias}.customers_email AS `{$prefix}customers_email`",
						"{$alias}.customers_id AS `{$prefix}customers_id`",
						"{$alias}.customers_name AS `{$prefix}customers_name`",
						"{$alias}.customers_postcode AS `{$prefix}customers_postcode`",
						"{$alias}.customers_state AS `{$prefix}customers_state`",
						"{$alias}.customers_street AS `{$prefix}customers_street`",
						"{$alias}.customers_suburb AS `{$prefix}customers_suburb`",
						"{$alias}.customers_telephone AS `{$prefix}customers_telephone`",
						"{$alias}.billing_city AS `{$prefix}billing_city`",
						"{$alias}.billing_company AS `{$prefix}billing_company`",
						"{$alias}.billing_country AS `{$prefix}billing_country`",
						"{$alias}.billing_name AS `{$prefix}billing_name`",
						"{$alias}.billing_postcode AS `{$prefix}billing_postcode`",
						"{$alias}.billing_state AS `{$prefix}billing_state`",
						"{$alias}.billing_street AS `{$prefix}billing_street`",
						"{$alias}.billing_suburb AS `{$prefix}billing_suburb`",
						"{$alias}.delivery_city AS `{$prefix}delivery_city`",
						"{$alias}.delivery_company AS `{$prefix}delivery_company`",
						"{$alias}.delivery_country AS `{$prefix}delivery_country`",
						"{$alias}.delivery_name AS `{$prefix}delivery_name`",
						"{$alias}.delivery_postcode AS `{$prefix}delivery_postcode`",
						"{$alias}.delivery_state AS `{$prefix}delivery_state`",
						"{$alias}.delivery_street AS `{$prefix}delivery_street`",
						"{$alias}.delivery_suburb AS `{$prefix}delivery_suburb`",
						"{$alias}.payment_method AS `{$prefix}payment_method`",
						"{$alias}.last_modified AS `{$prefix}last_modified`",
						"{$alias}.date_purchased AS `{$prefix}date_purchased`",
						"{$alias}.orders_date_finished AS `{$prefix}orders_date_finished`",
						"{$alias}.orders_status AS `{$prefix}orders_status`",
						"{$alias}.currency AS `{$prefix}currency`",
						"{$alias}.currency_value AS `{$prefix}delivery_suburb`",
						"{$alias}.paygate_order_id AS `{$prefix}paygate_order_id`",
						"{$alias}.shipping_method AS `{$prefix}shipping_method`"
		
		);

		return implode(',', $arrValue);
	}
}